<template>
    <div class="noticeManageEdit">
        <h2 class="my-big-font">编辑账户余额不足预警</h2>
        <div class="noticeManage-content">
            <div class="noticeManage-l">
                <h6 class="title">账户余额不足预警</h6>
                <div class="content">
                    <span>当{{waring.type}}余额不足</span>
                    <input class="moneyInp" type="text" name="" v-model="waring.waringMoney">
                    <span>元时，短信通知给</span>
                    <input class="phoneInp" type="text" name="" v-model="waring.phone">
                    <span>。（填写多个手机号时，用“,”隔开。）</span>
                </div>
            </div>
        </div>
        <div class="btn-box">
            <span class="my-btn btn1" @click="onclickSure">确定</span>
            <span class="my-btn btn2" @click="onclickCancel">取消</span>
        </div>
    </div>
</template>

<script>
export default {
    data(){
        return{
            waring:{
              id:'',
              waringMoney:'',
              type:'',
              phone:'',
            }
        }
    },
    mounted(){
        this.id=this.$route.query.id
        this.getOne()
    },
    methods:{
        //查询一条
        getOne(){
          this.axios.post('/recharge/sys/waring/info/'+this.id).then(result=>{
            this.waring = result.data.waring
            if (this.waring) {
                if(this.waring.type==1){
                  this.waring.type='158平台话费充值'
                }else if(this.waring.type==2){
                  this.waring.type='易通峰联'
                }
            }
            console.log("--------"+this.waring)
          })
        },
        //确定
        onclickSure(){
            if (this.waring) {
              if(this.waring.type=='158平台话费充值'){
                this.waring.type=1
              }else if(this.waring.type=='易通峰联'){
                this.waring.type=2
              }
            }
            this.axios.post("/recharge/sys/waring/update",this.waring).then(result=>{
                if(result.data.message=='success'){
                  this.$alert("修改成功").then()
                  this.$router.push('/index/noticeManage')
                }
            })
        },
        //取消
        onclickCancel(){
            this.$router.push('/index/noticeManage')
        }
    }
}
</script>

<style scoped>
.noticeManageEdit{
    padding: 30px 82px 50px 30px;
    background: #fff;
    margin: 10px 0 0 10px;
    color: #333333;
    min-height: calc(100vh - 96px);
    position: relative;
}
.noticeManageEdit h2{
    padding-top: 0;
}
/* 内容 */
.noticeManage-content{
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    padding-left: 0;
    color: #444;
}
.noticeManage-l .content{
    font-size: 15px;
    margin-top: 13px;
    display: flex;
    align-items: center;
}
/* input */
input{
    height: 30px;
    margin: 0 5px;
    padding-left: 10px;
}
.moneyInp{
    width: 70px;
}
.phoneInp{
    width: 270px;
}
/* 按钮 */
.my-btn{
    width: 75px;
    height: 31px;
    line-height: 27px;
    font-size: 15px;
}
.noticeManageEdit .btn-box{
    padding: 30px 0px;
}
.noticeManageEdit .btn-box span{
    margin-right: 15px;
    border: 2px solid rgba(255, 218, 59, 1);
}
.noticeManageEdit .btn-box .btn2{
    border: 2px solid #ddd;
    background: #fff;
}
</style>